<?php
namespace Admin\Controller;
use Think\Controller;
class SysController extends Controller{
    public function index(){
        $this->display();
    }
    public function add(){

		$id=$_GET['id'];
		if($id){
			$type=D('Type');
			$list=$type->find($id);
			if(strlen($list['pid'])>0 && isset($list['path'])){
				// $pid=$_GET['pid'];
				$list['path']=$list['path'].$id.",";
			}
		}else{
				$list['pid']=0;
				$list['path']=$list['pid'].',';
				$list['name']='';
			}
		
		// dump($list);exit;
		$type=D('type');
		if(IS_POST){
			$info=$type->create();          
            if($info){
    			if($type->add()){
    				$this->success('添加成功','index');
    			}
    		}else{
    			$this->error($type->getError());
    		}
		}else{

			$this->assign('list',$list);
			$this->display();
		}
	}
    
}